//
//  DetailHeaderLabelCell.m
//  SuperNews
//
//  Created by dllo on 16/1/20.
//  Copyright © 2016年 qiang. All rights reserved.
//

#import "DetailHeaderLabelCell.h"

@implementation DetailHeaderLabelCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    self.label = [[UILabel alloc] init];
    self.label.numberOfLines = 0;
    self.label.font = [UIFont systemFontOfSize:16.0];
    //    self.label.backgroundColor = [UIColor brownColor];
    [self.contentView addSubview:self.label];
    
    self.imageHeader = [[UIImageView alloc] init];
    self.imageHeader.layer.cornerRadius = 25;
    self.imageHeader.layer.masksToBounds = YES;
    [self.contentView addSubview:self.imageHeader];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameLabel];
    self.nameLabel.font = [UIFont systemFontOfSize:15.0];
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [self.contentView addSubview:self.titleLabel];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(107, 30, 1, 10)];
    view.backgroundColor = [UIColor colorWithRed:0.6554 green:0.6554 blue:0.6554 alpha:1.0];
    [self.contentView addSubview:view];
    
    self.detailButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.detailButton setImage:[UIImage imageNamed:@"detail_expand_arrow"] forState:UIControlStateNormal];
    [self.detailButton addTarget:self action:@selector(detailClickAction) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.detailButton];
}

- (void)detailClickAction
{
    [self.delegate handleClick];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.label.frame = CGRectMake(75, 55, [UIScreen mainScreen].bounds.size.width - 75, 120);
    self.imageHeader.frame = CGRectMake(15, 15, 50, 50);
    self.nameLabel.frame = CGRectMake(75, 15, 30, 40);
    self.titleLabel.frame = CGRectMake(110, 15, 200, 40);
    self.detailButton.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width - 40) / 2.0, 175, 40, 30);
}

@end
